forum

Home / DeveloperSection / Forums / how do you bind datagridview with chart?

how do you bind datagridview with chart?

Ho Hui Jun 2787 29-Dec-2015
hi there, I really need help on this project that I am dealing with. It is to calculate free surface effect of a vessel on large angle which I have no idea where it when wrong.

how do you bind datagridview with chart?
it doesn't show any chart on the right side. 
below is the code for the chart. I do appreciate if anyone could help me with this.

Private Sub GZChart_Click(sender As Object, e As EventArgs) Handles GZChart.Click
        GZChart.ChartAreas.Add("area")
        GZChart.ChartAreas("area").AxisX.Minimum = 0
        GZChart.ChartAreas("area").AxisY.Minimum = 0
        GZChart.ChartAreas("area").AxisX.Maximum = 100
        GZChart.ChartAreas("area").AxisY.Maximum = 20
        GZChart.ChartAreas("area").AxisX.Interval = 10
        GZChart.ChartAreas("area").AxisX.Interval = 0.5
        GZChart.Series("Series1").Color = Color.Red
        GZChart.Series("Series1").ChartType = DataVisualization.Charting.SeriesChartType.SplineArea
        GZChart.Series.Clear()
        GZChart.Series.Add("Series1")
        GZChart.Series("Series1").Points.Clear()
        GZChart.Series("Series1").Points.AddXY(DataGridView.Columns(3).HeaderText & "--", DataGridView.Rows(0).Cells(1).Value, DataGridView.Rows(0).Cells(3).Value)
        GZChart.Series("Series1").Points.AddXY(DataGridView.Columns(3).HeaderText & "--", DataGridView.Rows(1).Cells(1).Value, DataGridView.Rows(1).Cells(3).Value)
        GZChart.Series("Series1").Points.AddXY(DataGridView.Columns(3).HeaderText & "--", DataGridView.Rows(2).Cells(1).Value, DataGridView.Rows(2).Cells(3).Value)
        GZChart.Series("Series1").Points.AddXY(DataGridView.Columns(3).HeaderText & "--", DataGridView.Rows(3).Cells(1).Value, DataGridView.Rows(3).Cells(3).Value)
        GZChart.Series("Series1").Points.AddXY(DataGridView.Columns(3).HeaderText & "--", DataGridView.Rows(4).Cells(1).Value, DataGridView.Rows(4).Cells(3).Value)
        GZChart.Series("Series1").Points.AddXY(DataGridView.Columns(3).HeaderText & "--", DataGridView.Rows(5).Cells(1).Value, DataGridView.Rows(5).Cells(3).Value)
        GZChart.Series("Series1").Points.AddXY(DataGridView.Columns(3).HeaderText & "--", DataGridView.Rows(6).Cells(1).Value, DataGridView.Rows(6).Cells(3).Value)
        GZChart.Series("Series1").Points.AddXY(DataGridView.Columns(3).HeaderText & "--", DataGridView.Rows(7).Cells(1).Value, DataGridView.Rows(7).Cells(3).Value)
        GZChart.Series("Series1").Points.AddXY(DataGridView.Columns(3).HeaderText & "--", DataGridView.Rows(8).Cells(1).Value, DataGridView.Rows(8).Cells(3).Value)
        GZChart.Series("Series1").Points.AddXY(DataGridView.Columns(3).HeaderText & "--", DataGridView.Rows(9).Cells(1).Value, DataGridView.Rows(9).Cells(3).Value)
    End Sub

  

Updated on 08-Jan-2016

Can you answer this question?


Answer

2 Answers

Liked By